﻿using System.Collections;
using System.Collections.Generic;
using DataAccess.Stock;
using Model;

namespace Service
{

    public class StockService : ServiceBase
    {
        StockDataAccess mgr;
        public StockService()
        {
            mgr = new StockDataAccess();
        }
        public virtual void Save(Equipment equipment)
        {
            mgr.Save(equipment);
        }
        public void Update(Equipment equipment)
        {
            mgr.Save(equipment);
        }
        public void Delete(Equipment equipment)
        {
            mgr.Delete(equipment);
        }
        public void Delete(int equipmentId)
        {
            string query = "FROM Equipment WHERE EquipmentId = " + equipmentId;
            mgr.DeleteObject(query);
        }
        public void DeleteEmployee(int employeeId)
        {
            string query = "From Employee where EmployeeId =" + employeeId;
            mgr.DeleteObject(query);
        }
        public void DeleteSystem(int systemId)
        {

            string query = "From EquipmentSystem where SystemId=" + systemId;
            mgr.DeleteObject(query);
        }
        public void DeleteModel(int modelId)
        {
            string query = "From EquipmentModel where ModelId=" + modelId;
            mgr.DeleteObject(query);
        }
        public void DeleteDepartment(int departmentId)
        {

            string query = "From Department where DepartmentId=" + departmentId;
            mgr.DeleteObject(query);

        }
        public void DeleteCompany(int companyId)
        {

            string query = "From Company where CompanyId=" + companyId;
            mgr.DeleteObject(query);

        }


        public Equipment GetEquipment(int equipmentId)
        {
            return mgr.Get(typeof(Equipment), equipmentId) as Equipment;
        }
        public Sparepart GetSparepart(int sparepartId)
        {
            return
                mgr.GetListByPropertyValue(typeof (Sparepart), Sparepart.CONST_INFORMATION_ID, sparepartId)[0] as
                Sparepart;
            ;
        }
        public IList GetEquipmentTypeSystem(int typeId, int  systemId)
        {
            return mgr.GetEquipmentTypeSystem(typeId, systemId);
        }
        public Employee GetEmployee(int employeeId)
        {

            return mgr.Get(typeof (Employee), employeeId) as Employee;

        }
        public EquipmentSystem GetSystem(int systemId)
        {
            
            return mgr.Get(typeof(EquipmentSystem), systemId) as EquipmentSystem;

        }
        public IList GetSystem()
        {
            return mgr.Get(typeof(EquipmentSystem));
        }
        public IList GetModel()
        {
             return mgr.Get(typeof(EquipmentModel));

        }
        public IList GetDepartment()
        {
            return mgr.Get(typeof (Department));
        }
        public IList GetCompany()
        {
            return mgr.Get(typeof (Company));
        }
        public IList GetEquipments()
        {
            return mgr.Get(typeof(Equipment));
        }
        public EquipmentOwner GetEquipmentOwner(string codeNumber)
        {
            return mgr.GetEquipmentOwner(codeNumber);
        }
        public EquipPurchaseInfo GetPurchaseInfo(int purchaseInfoId)
        {
            return mgr.GetPurchaseInfo(purchaseInfoId);
        }
        public IList GetPurchaseInfo()
        {
            return mgr.GetByOrder(typeof(EquipPurchaseInfo), EquipPurchaseInfo.CONST_PO_NUMBER);
        }
        public IList GetGroupeSoftware()
        {
            return mgr.Get(typeof(GroupeSoftware));

        }
        public void DeleteGroupeSoftware(int groupeSoftwareId)
        {

            string query = "From GroupeSoftware where GroupeSoftwareId=" + groupeSoftwareId;
            mgr.DeleteObject(query);
            

        }
        public void UpdatePurchaseInfo(EquipPurchaseInfo model)
        {
            mgr.Save(model);
        }
        public void UpdateEmployee(Employee employee)
        {
            mgr.Save(employee);
        }
        public void UpdateSystem(EquipmentSystem system)
        {
            mgr.Save(system);
            //mgr.Update(system);
        }
        public void InsertPurchaseInfo(EquipPurchaseInfo model)
        {
            mgr.Save(model);
        }
        public void InsertSparepartComposeEquip(SparepartComposeEquipment model)
        {
            mgr.Save(model);
        }
     
        public void InsertSparepart(Sparepart model)
        {
            mgr.Save(model);
        }
        public void InsertSparepartInfo(SparepartPurchaseInfo model)
        {
            mgr.Save(model);
        }
        public void InsertEquipmentOwner(EquipmentOwner model)
        {
            mgr.Save(model);
        }
        public SparepartComposeEquipment GetSparepartComposeEquip(string codeNumber)
        {
            return mgr.GetSparepartComposeEquip(codeNumber);
    }

        public void UpdateEquipmentOwner(EquipmentOwner model)
        {
            mgr.Save(model);
        }
        public IList GetStockEmployees()
        {
            return mgr.GetStockEmployees();
        }
        public int GetMaxEquipmentCodeNumber()
        {
            return mgr.GetMaxEquipmentCodeNumber();
        }

        public void SaveEmployee(Employee employee)
        {
            mgr.Save(employee);
        }
        public IList GetWarrantyListToBeAlerted()
        {
            return mgr.GetStockEmployees();
        }
        public IList GetEquipmentWarrantyAlert(int beforeWarranty)
        {
            return mgr.GetEquipmentWarrantyAlert(beforeWarranty);
        }
        public SparepartPurchaseInfo GetPurchaseInformation(int sparepartInfoId)
        {
            return (SparepartPurchaseInfo)mgr.GetListByPropertyValue(typeof(SparepartPurchaseInfo), "SparepartPurchaseInfoId", sparepartInfoId)[0];
        }
        public void UpdatePurchaseInformation(SparepartPurchaseInfo sparepart)
        {
            mgr.Save(sparepart);
        }
        public void UpdateSparepart(Sparepart sparepart)
        {
            mgr.Save(sparepart);
        }

        public void SaveComputerInfo(ComputerInfo model)
        {
            mgr.Save(model);
        }
        public void SaveEquipmentSparepart(EquipmentSparepart model)
        {
            mgr.Save(model);
        }
        public void DeleteEquipmentSparepart(EquipmentSparepart model)
        {
            mgr.Delete(model);
        }
        public void SaveComputerSoftware(ComputerSoftware model)
        {
            mgr.Save(model);
        }
        public void DeleteComputerSoftware(ComputerSoftware model)
        {
            mgr.Delete(model);
        }
        public void DeleteSparepartCompose(string codeNumber)
        {

           mgr.DeleteSparepartCompose(codeNumber);
        }

        public void DeleteSparepart(int informationId)
        {

            mgr.DeleteSparepart(informationId);
        }
        public void DeleteSparepartInfo(int informationId)
        {
            mgr.DeleteSparepartInfo(informationId);
        }
        public Sparepart GetSparepart(string codeNumber)
        {
            return mgr.GetSparepart(codeNumber);
        }





    }
}
